/*

*/
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

const int N = 1e6 + 10;
int a[N], b[N], c[N];
int cnt_a[N], cnt_c[N];
int n;
int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++)
        scanf("%d", &b[i]);
    for (int i = 1; i <= n; i++)
        scanf("%d", &c[i]);
    sort(a + 1, a + n + 1);
    sort(b + 1, b + n + 1);
    sort(c + 1, c + n + 1);
    // 统计a[]<b[i]的数量 双指针 O(n);
    long long res = 0;
    int start = 1;
    int flag_a = 0, flag_c = 0;
    for (int i = 1; i <= n; i++)
    {
        int temp = b[i];
        while (flag_a < n)
        {
            if (a[flag_a + 1] >= temp)
                break;
            flag_a++;
        }

        while (flag_c < n)
        {
            if (c[flag_c + 1] >= temp)
                break;
            flag_c++;
        }
        cout << flag_a << " " << n - flag_c << endl;
        res += (long long)flag_a * (n - flag_c);
        cout << res << endl;
    }
    cout << res << endl;
    return 0;
}